package com.example.myactspringboot.Interceptor;

import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author Zhouchb
 * @Create 2024-03-11 21:41
 * @Description
 */
@Configuration
public class FilterConfig {
    //过滤器
    @Bean("urlFilter")
    public MyFilter urlFilter() {
        System.out.println("注册过滤器1......");
        return new MyFilter();
    }

    //注册过滤器
    @Bean
    public FilterRegistrationBean filterRegistrationBean() {
        System.out.println("注册过滤器......");
        FilterRegistrationBean filterReg = new FilterRegistrationBean();
        filterReg.setFilter(urlFilter());
        filterReg.addUrlPatterns("/remote1");
        filterReg.setOrder(1);
        return filterReg;
    }
}
